# Kernel config based on: arch/arm/configs/cyanogenmod_tuna_defconfig

pkgname="linux-samsung-maguro"
pkgver=3.0.31
pkgrel=9
pkgdesc="Samsung Galaxy Nexus kernel from LineageOS"
arch="armhf"
_carch="arm"
_flavor="samsung-maguro"
url="https://github.com/LineageOS/android_kernel_samsung_tuna"
license="GPL2"
options="!strip !check !tracedeps"
makedepends="perl sed installkernel bash gmp-dev bc linux-headers elfutils-dev"
HOSTCC="${CC:-gcc}"
HOSTCC="${HOSTCC#${CROSS_COMPILE}}"

# Source
_repository="android_kernel_samsung_tuna"
_commit="e14e5fe679a63eef92346cde874175d8b62b6a4a"
_config="config-${_flavor}.armhf"
source="
	$pkgname-$_commit.tar.gz::https://github.com/LineageOS/${_repository}/archive/${_commit}.tar.gz
	$_config
	compiler-gcc6.h
	android_paranoid_network.patch
	fix_old_perl_code.patch
"
builddir="$srcdir/${_repository}-${_commit}"

prepare() {
	default_prepare

	# gcc6 support
	cp -v "$srcdir/compiler-gcc6.h" "$builddir/include/linux/"

	cp "$srcdir"/$_config "$builddir"/.config
	make ARCH="$_carch" HOSTCC="$HOSTCC" silentoldconfig
}

menuconfig() {
	cd "$builddir"
	make ARCH="$_carch" menuconfig
	cp .config "$startdir"/$_config
}

build() {
	unset LDFLAGS
	make ARCH="$_carch" CC="${CC:-gcc}" \
		KBUILD_BUILD_VERSION="$((pkgrel + 1 ))-Alpine"
}

package() {
	install -Dm644 "$builddir/arch/arm/boot/zImage" \
		"$pkgdir/boot/vmlinuz-$_flavor"

	install -D "$builddir/include/config/kernel.release" \
		"$pkgdir/usr/share/kernel/$_flavor/kernel.release"
}

sha512sums="f117b3202c3db1a575598fd87ee27080db5c447c986ced677b63e6b00613ebfab58d634bf63b8bcf0c229eb0bec4dc81b13d7cfda3c2aee62e9ed8e26eeb860c  linux-samsung-maguro-e14e5fe679a63eef92346cde874175d8b62b6a4a.tar.gz
6ba270b415506ef4e0a34dcd775d9d59cb749d2a1f4b9863444b866567ed7b05594215ae5ae4f8d302be826a64df97e6824ef38184b7566026d0e73801ed528b  config-samsung-maguro.armhf
d80980e9474c82ba0ef1a6903b434d8bd1b092c40367ba543e72d2c119301c8b2d05265740e4104ca1ac5d15f6c4aa49e8776cb44264a9a28dc551e0d1850dcc  compiler-gcc6.h
d8cdc1137e6a4ad78a3a31acc40f0c98f4db272eaf5b90ee850abb83b80916c4ff3c18a0a181e94eebead44213f6314e3363d0c4b91d95ee1adafbcad6dc57ab  android_paranoid_network.patch
65eb11dca6645073885228af6aae6efa40b6f063fd04157b501acf40368bf331dd701f746ed187659f654a9354ddf304aaefca8ffc9ea2b00c145c61162e1189  fix_old_perl_code.patch"
